class: center, middle, inverse, title-slide # Management and Analysis of Georeferenced Survey Data ## MZES Social Science Data Lab ### Stefan Jünger, October 21, 2020 --- layout: true --- ## Topics .pull-left[ - Space in the social sciences - Georeferenced (survey) data & geospatial data - Challenges - Methods & Applications - Hands-on in `R` ] .pull-right[ <img src="data:image/png;base64,#./auxiliarily_files/img/fig_framework.png" width="660" style="display: block; margin: auto;" /> .right[.tinyisher[Jünger, 2019]] ] --- class: center, middle ## Space in the Social Sciences --- </br> </br> <img src="data:image/png;base64,#./auxiliarily_files/img/park_etal.png" width="55%" style="display: block; margin: auto;" /> .right[.tinyisher[Park et al. 1925]] --- ## Space & Place - Is It Really That New? .pull-left[ Space has been a topic already for a long time and is incorporated into classic theories, e.g., Allport‘s Contact Theory (1954) <img src="data:image/png;base64,#https://images.fr.shopping.rakuten.com/photo/874882994.jpg" width="50%" style="display: block; margin: auto;" /> .center[.tinyisher[https://images.fr.shopping.rakuten.com/photo/874882994.jpg]] ] .pull-right[ <img src="data:image/png;base64,#https://i.gr-assets.com/images/S/compressed.photo.goodreads.com/books/1387595670l/7034925.jpg" width="35%" style="display: block; margin: auto;" /> .center[.tinyisher[https://i.gr-assets.com/images/S/compressed.photo.goodreads.com/books/1387595670l/7034925.jpg]] Subject of Urban Studies and regional sociology and—more or less naturally—in the environmental social sciences (e.g., for classic reference, see Siegfrid, 1913) ] --- ## From the Past to (Almost) Today </br> Qualitative and theoretical work is manifold - A lot of regionally limited studies - Difficult to translate to... </br> ...quantitative research - Space often defined by data (Petrović et al., 2019) - e.g., administrative borders - Neighborhood as ‘container’ --- ## Today .pull-left[ Increased amount of available data - Quantitative and on a small spatial scale </br> <img src="data:image/png;base64,#./auxiliarily_files/img/tools_today.png" width="60%" style="display: block; margin: auto;" /> ] .pull-right[ <img src="data:image/png;base64,#./auxiliarily_files/img/geo_today.png" width="816" style="display: block; margin: auto;" /> Better tools - Personal computer with enough horse power - Standard software, such as `R`, can be used as Geographic Information System (GIS) ] --- class: center, middle ## Georeferenced Data --- ## What Are Georeferenced Data? .pull-left[ </br> Data with a direct spatial reference `\(\rightarrow\)` **geo-coordinates** - Information about geometries - Optional: Content in relation to the geometries ] .pull-right[ <img src="data:image/png;base64,#./auxiliarily_files/img/fig_geometries.png" width="85%" style="display: block; margin: auto;" /> .tinyisher[Sources: OpenStreetMap / GEOFABRIK (2018), City of Cologne (2014), and the Statistical Offices of the Federation and the Länder (2016) / Jünger, 2019] ] --- ## Georeferenced Survey Data Survey data enriched with geo-coordinates (or other direct spatial references) </br> <img src="data:image/png;base64,#./auxiliarily_files/img/geo_surveys.png" width="85%" style="display: block; margin: auto;" /> </br> .center[**With georeferenced survey data, we can analyze interactions between individual behaviors and attitudes and the environment.**] --- ## Prerequisite: Geocoding .pull-left[ Indirect spatial references have to be converted into direct spatial references `\(\rightarrow\)` Addresses to geo-coordinates Different service providers can be used - e.g., Google, Bing, OSM - In Germany: Federal Agency of Cartography and Geodesy (BKG) ] .pull-right[ </br> </br> <img src="data:image/png;base64,#./auxiliarily_files/img/geocoding.png" width="785" style="display: block; margin: auto;" /> ] --- ## Georeferenced Survey Data `\(\neq\)` Geospatial Data .pull-left[ We must not store geo-coordinates and survey data in one dataset - Differences to geospatial data - More complicated workflow to work with (see Challenges) ] .pull-right[ <img src="data:image/png;base64,#./auxiliarily_files/img/fig_linking_workflow_simple.png" width="85%" style="display: block; margin: auto;" /> .right[.tinyisher[Jünger, 2019]] ] --- ## Geospatial Data </br> Essentially georeferenced data as defined before - Information about geometries and related information Can be projected jointly in one single space - Allows data linking and extraction of substantial information </br> .center[**This is why they can serve as auxiliary information, i.e., context data, for survey data!**] --- ## What Is GIS? Most common understanding: Geographic Information Systems (GIS) as specific software to process geospatial data for - Visualization - Analysis <img src="data:image/png;base64,#./auxiliarily_files/img/gis.png" width="70%" style="display: block; margin: auto;" /> .center[.tinyisher[Screenshot of the Open Source GIS [`QGIS`](https://qgis.org)]] --- ## Data Specifics .pull-left[ </br> </br> <img src="data:image/png;base64,#./auxiliarily_files/img/fig_3d_simple.png" width="9083" style="display: block; margin: auto;" /> .tinyisher[Sources: OpenStreetMap / GEOFABRIK (2018) and City of Cologne (2014)] ] .pull-right[ Formats - Vector data (points, lines, polygons) - Raster data (grids) Coordinate reference systems - Allow the projection on earth‘s surface - Differ in precision for specific purposes ] --- ## Layers Must Match! </br> <img src="data:image/png;base64,#./auxiliarily_files/img/fig_projections.png" width="9956" style="display: block; margin: auto;" /> .tinyisher[Source: Statistical Office of the European Union Eurostat (2018) / Jünger, 2019] --- class: center, middle ## Challenges --- ## Data Availability .pull-left[ Geospatial Data - Often de-centralized distributed - Fragmented data landscape, at least in Germany Georeferenced Survey Data - Primarily survey data - Depends on documentation - Access difficult due to data protection restrictions ] .pull-right[ <img src="data:image/png;base64,#./auxiliarily_files/img/data_availability.png" width="75%" style="display: block; margin: auto;" /> .right[.tinyisher[ https://www.eea.europa.eu/data-and-maps https://datasearch.gesis.org/ https://datasetsearch.research.google.com/ ]] ] --- ## Technical Procedures .pull-left[ </br> .center[<img src="./auxiliarily_files/img/angry_cat.gif" width="75%">] .center[.tinyisher[https://giphy.com/gifs/VbnUQpnihPSIgIXuZv]] ] .pull-right[ Geocoding - Reasonable automated procedure - But differ in quality and access rights - High risk for data protection GIS procedures - Requires exploiting specialized software - Can get complex and resource intensive ] --- ## Data Protection </br> </br> That‘s one of the biggest issues - Explicit spatial references increase risk of re-identifying anonymized survey respondents - Can occur during the processing of data but also during the analysis </br> .center[**Affects all phases of research and data management!**] --- ## Legal Regulations .pull-left[ Storing personal information such as addresses in the same place as actual survey attributes is not allowed in Germany - Projects store them in separate locations - Can only be matched with a correspondence table - Necessary to conduct data linking ] .pull-right[ <img src="data:image/png;base64,#./auxiliarily_files/img/fig_linking_workflow_simple.png" width="949" style="display: block; margin: auto;" /> .right[.tinyisher[Jünger, 2019]] ] --- ## Distribution & Re-Identification Risk Data may still be sensitive - Geospatial attributes add new information to existing data - May be part of general data privacy checks, but we may not distribute these data as is .pull-left[ Safe Rooms / Secure Data Centers - Control access - Checks output ] .pull-right[ <img src="data:image/png;base64,#./auxiliarily_files/img/safe_room.png" width="825" style="display: block; margin: auto;" /> .right[.tinyisher[https://www.gesis.org/en/services/processing-and-analyzing-data/guest-research-stays/secure-data-center-sdc]] ] --- ## Social Spatial Research Data Infrastructure (SoRa) Project for an easy spatial linking of survey data from the SOEP and GESIS Panel with indicators from the IOER-Monitor: www.sora-projekt.de </br> <img src="data:image/png;base64,#./auxiliarily_files/img/sora_consortium.png" width="75%" style="display: block; margin: auto;" /> --- ## It’s a Web-Based Tool .pull-left[ </br> Users can start a linking project using their web browser - Selection of survey data - Selection of land use indicators - Selection of linking method ] .pull-right[ </br> <video width="320" height="240" autoplay> <source src="./auxiliarily_files/img/sora_1.mp4" type="video/mp4"> </video> ] --- class: center, middle ## Methods & Applications --- ## Spatial Linking <img src="data:image/png;base64,#./auxiliarily_files/img/fig_3d_.png" width="45%" style="display: block; margin: auto;" /> .tinyisher[Sources: OpenStreetMap / GEOFABRIK (2018), City of Cologne (2014), Leibniz Institute of Ecological Urban and Regional Development (2018), Statistical Offices of the Federation and the Länder (2016), and German Environmental Agency / EIONET Central Data Repository (2016) / Jünger, 2019] --- ## Spatial Linking Methods (Examples) I .pull-left[ 1:1 <img src="data:image/png;base64,#./auxiliarily_files/img/fig_linking_by_location_noise.png" width="75%" style="display: block; margin: auto;" /> ] .pull-right[ Distances <img src="data:image/png;base64,#./auxiliarily_files/img/fig_linking_distance_noise_appI.png" width="75%" style="display: block; margin: auto;" /> ] .tinyisher[Sources: German Environmental Agency / EIONET Central Data Repository (2016) and OpenStreetMap / GEOFABRIK (2018) / Jünger, 2019] --- ## Spatial Linking Methods (Examples) II .pull-left[ Filter methods <img src="data:image/png;base64,#./auxiliarily_files/img/fig_linking_focal_immigrants.png" width="75%" style="display: block; margin: auto;" /> ] .pull-right[ Buffer zones <img src="data:image/png;base64,#./auxiliarily_files/img/fig_linking_buffer_sealing.png" width="75%" style="display: block; margin: auto;" /> ] .tinyisher[Sources: Leibniz Institute of Ecological Urban and Regional Development (2018) and Statistical Offices of the Federation and the Länder (2016) / Jünger, 2019] --- ## Application I: Road Traffic Noise, Marriage, and Health > Do married people who are affected by road traffic noise report less health issues than unmarried people? .pull-left[ .small[ Theoretical Framework - Dyadic Coping (Bodenman, 1997) - Social Buffering (Thoits, 2011) - Stress Process (Pearlin et al., 2005) Data - GGSS 2014 - Road traffic noise at address ] ] .pull-right[ <img src="data:image/png;base64,#./auxiliarily_files/img/fig_linking_distance_noise_appI.png" width="65%" style="display: block; margin: auto;" /> .tinyisher[Sources: Statistical Offices of the Federation and the Länder (2016) / Jünger, 2019] ] --- ## Structural Equation Model (SEM) <img src="data:image/png;base64,#./auxiliarily_files/img/fig_sem_general.png" width="40%" style="display: block; margin: auto;" /> .right[.tinyisher[Jünger, 2019]] --- ## Multi-Group SEM .pull-left[ <img src="data:image/png;base64,#./auxiliarily_files/img/fig_sem_married.png" width="75%" style="display: block; margin: auto;" /> ] .pull-right[ <img src="data:image/png;base64,#./auxiliarily_files/img/fig_sem_unmarried.png" width="75%" style="display: block; margin: auto;" /> ] .tinyisher[Data Source: Georeferenced German General Social Survey (GESIS - Leibniz Institute for the Social Sciences, 2015, 2018); all models are controlled for age, gender, income, education, smoking, and municipality size (N = 3,138)] --- ## Application II: Political Attitudes (based on Klinger et al., 2017) > Do people who live in native-homogenous neighborhoods bordered by ethnically-diverse neighborhoods tend to be more xenophobic? .pull-left[ .smaller[ Theoretical Framework - Contact Theory (Allport, 1954) - Intergroup Threat (Stephan et al., 2009) / Ethnic Competition (Banton, 1983; Blalock, 1967; Blumer, 1958) `\(\rightarrow\)` **Halo Hypothesis** (Bowyer, 2008; Rydgren & Ruth, 2013) Data - GGSS 2014 - Immigrants rates of 1 km² neighborhoods ] ] .pull-right[ <img src="data:image/png;base64,#./auxiliarily_files/img/fig_linking_focal_immigrants.png" width="65%" style="display: block; margin: auto;" /> .tinyisher[Sources: Statistical Offices of the Federation and the Länder (2016) / Jünger, 2019] ] --- ## The Halo Effect Hypothesis </br> <img src="data:image/png;base64,#./auxiliarily_files/img/fig_halo_example.png" width="62%" style="display: block; margin: auto;" /> .tinyisher[Sources: Statistical Offices of the Federation and the Länder (2016) and Federal Agency for Cartography and Geodesy (2018) / Jünger, 2019] --- ## Variation .pull-left[ Neighborhood sizes - direct - surrounding Statistics - Maximum - Mean - Municipality ] .pull-right[ Relationships - Ratio - Difference - Interaction <img src="data:image/png;base64,#./auxiliarily_files/img/fig_linking_focal_immigrants.png" width="50%" style="display: block; margin: auto;" /> .tinyisher[German Environmental Agency / EIONET Central Data Repository (2016) and OpenStreetMap / GEOFABRIK (2018) / Jünger, 2019] ] --- ## Null Effects (Spatial Lag Model) </br> <img src="data:image/png;base64,#./auxiliarily_files/img/fig_appII_coefplot_autcov.png" width="75%" style="display: block; margin: auto;" /> .tinyisher[Multiple imputated data from the georeferenced GGSS 2014; standardized regression coefficients of a spatial lag Y model; all estimates are controlled for age, gender, eductation, income, employment status, homeownership, inhabitants and mean flat size in 1 km² neighborhoods, municipality size, and region of Germany (East/West); N = 1,192] --- ## Application III: Environmental Inequalties (Work In Progress) > Is income associated with less environmental disadvantages, and are there differences between German people and people with a migration background? .pull-left[ .small[ Theoretical Framework - Social and Ethnic Inequalities (Crowder & Downey, 2010) - Place Stratification (Lersch, 2013) Data - GGSS 2016 & 2018 - soil sealing & green spaces ] ] .pull-right[ <img src="data:image/png;base64,#./auxiliarily_files/img/fig_linking_buffer_sealing.png" width="65%" style="display: block; margin: auto;" /> .tinyisher[Leibniz Institute of Ecological Urban and Regional Development (2018) / Jünger, 2019] ] --- ## Estimates: Soil Sealing <img src="data:image/png;base64,#./auxiliarily_files/img/fig_prediction_sealing_with_income_interaction_unofficial.png" width="70%" style="display: block; margin: auto;" /> .tinyisher[Data source: GGSS 2016 & 2018; N = 6,117; 95% confidence intervals based on cluster-robust standard errors (sample point); all models control for age, gender, education, household size, german region and survey year interaction, inhabitant size of municipality, and distance to municipality administration] --- ## Estimates: Green Spaces <img src="data:image/png;base64,#./auxiliarily_files/img/fig_prediction_green_with_income_interaction_unofficial.png" width="70%" style="display: block; margin: auto;" /> .tinyisher[Data source: GGSS 2016 & 2018; N = 6,117; 95% confidence intervals based on cluster-robust standard errors (sample point); all models control for age, gender, education, household size, german region and survey year interaction, inhabitant size of municipality, and distance to municipality administration] --- class: center, middle ## Hand-On In `R` --- ## Fake Research Question .pull-left[ Say we're interested in the impact of the Corona crisis on individual well-being and the mediating role of environmental factors. We plan to conduct a survey in the city of Mannheim. As we are open source enthuasists, we do (almost) everything in `R`. ] .pull-right[ </br> <img src="data:image/png;base64,#./auxiliarily_files/img/4iq3kg.jpg" width="813" style="display: block; margin: auto;" /> .center[.tinyisher[https://imgflip.com/memegenerator/Trump-Bill-Signing] ] ] --- ## What Is `R`? >R is a free software environment for statistical computing and graphics. It compiles and runs on a wide variety of UNIX platforms, Windows and MacOS ([`R` Project website](https://www.r-project.org/)). `R` is [free and open-source software (FOSS)](https://en.wikipedia.org/wiki/Free_and_open-source_software) and also a programming language. More specifically, it is a free, non-commercial implementation of the [`S` programming language](https://en.wikipedia.org/wiki/S_(programming_language) (developed by Bell Laboratories). --- ## Don’t Worry, Please .pull-left[ </br> In the following, we'll see a lot of code - you don't have to understand everything - consider it as watching some steps in a cooking show ] .pull-right[ </br> </br> <img src="data:image/png;base64,#./auxiliarily_files/img/hacker_man.jpg" width="2560" style="display: block; margin: auto;" /> .center[.tinyisher[https://i.kym-cdn.com/entries/icons/original/000/021/807/ig9OoyenpxqdCQyABmOQBZDI0duHk2QZZmWg2Hxd4ro.jpg]] ] --- ## Piping In `R` Usually, in `R` we apply functions as follows: ```r f(x) ``` In the logic of pipes this function is written as: ```r x %>% f(.) ``` -- We can use pipes on more than one function: ```r x %>% f_1() %>% f_2() %>% f_3() ``` More details: https://r4ds.had.co.nz/pipes.html --- ## Geospatial Data In `R` There have been packages for geospatial data in `R` already for a long time. - [`sp`](https://cran.r-project.org/web/packages/sp/index.html) for vector data - [`raster`](https://cran.r-project.org/web/packages/raster/index.html) for raster data .pull-left[ Cutting-edge for vector data - [`sf`](https://cran.r-project.org/web/packages/sf/index.html), which implements the [ISO 19125](https://www.iso.org/standard/40114.html) standard for geospatial data, called "simple features". ] .pull-right[ <img src="data:image/png;base64,#./auxiliarily_files/img/sf.jpg" width="75%" style="display: block; margin: auto;" /> .tinyisher[Illustration by [Allison Horst](https://github.com/allisonhorst/stats-illustrations)] ] --- ## Simple Features in the `sf` Package Features are observations in data: > [A feature is thought of as a thing, or an object in the real world, such as a building or a tree](https://r-spatial.github.io/sf/articles/sf1.html) Simple features in `R` are - simple data frames with observations in the rows and variables in the columns - include a `geometry` column and some additional metadata, such as the coordinate reference system. --- ## Further Packages to Interface With the Internet (...And Geospatial Data) .pull-left[ Besides `sf`, we also use - [`osmdata`](https://cran.r-project.org/web/packages/osmdata/index.html) for using the [Overpass API](http://overpass-api.de/) of [OpenStreetMap](http://overpass-api.de/) - [`raster`](https://cran.r-project.org/web/packages/raster/index.html) for processing raster data - [`reticulate`](https://cran.r-project.org/web/packages/reticulate/index.html) to interface Python and to use the [`OWSLib`](https://github.com/geopython/OWSLib) to access geospatial data from the internet ] .pull-right[ </br> </br> .center[] .center[.tinyisher[https://66.media.tumblr.com/0e4f270fdebf2bbbc8a61ddae1cd13de/tumblr_mz7ksjhYpi1s6banvo1_250.gif]] ] --- ## Our Sample Area: Mannheim’s Boundaries .pull-left[ ```r mannheim <- osmdata::getbb("Mannheim") %>% osmdata::opq(timeout = 25*100) %>% osmdata::add_osm_feature( key = "admin_level", value = "6" ) %>% osmdata::osmdata_sf() %$% osm_multipolygons %>% dplyr::filter(name == "Mannheim") %>% dplyr::select(geometry) %>% sf::st_transform(3035) ``` ] -- .pull-right[ ```r ggplot(mannheim, fill = NA) + geom_sf() + ggsn::blank() ``` <img src="data:image/png;base64,#MZES_SSDL_Georeferenced_Survey_Data_files/figure-html/mannheim_plot-1.png" style="display: block; margin: auto;" /> ] --- ## Just for Fun I: Roads .pull-left[ ```r roads <- osmdata::getbb("Mannheim") %>% osmdata::opq(timeout = 25*100) %>% osmdata::add_osm_feature( key = "highway", value = c( "trunk", "primary", "secondary", "tertiary" ) ) %>% osmdata::osmdata_sf() %$% osm_lines %>% dplyr::select(geometry) %>% sf::st_transform(3035) %>% sf::st_intersection(mannheim) %>% dplyr::filter( sf::st_is(., "LINESTRING") ) ``` ] -- .pull-right[ ```r ggplot() + geom_sf(data = mannheim, fill = NA) + geom_sf(data = roads) + ggsn::blank() ``` <img src="data:image/png;base64,#MZES_SSDL_Georeferenced_Survey_Data_files/figure-html/map-osm-roads-1.png" style="display: block; margin: auto;" /> ] --- ## Just for Fun II: Buildings .pull-left[ ```r buildings <- osmdata::getbb("Mannheim") %>% osmdata::opq(timeout = 25*100) %>% osmdata::add_osm_feature( key = "building", value = c( "apartments", "commercial", "office", "cathredral", "church", "retail", "industrial", "warehouse", "hotel", "house", "civic", "government", "public", "parking", "garages", "carport", "transportation", "semidetached_house", "school", "conservatory" ) ) %>% osmdata::osmdata_sf() %$% osm_polygons %>% dplyr::select(geometry) %>% sf::st_transform(3035) %>% sf::st_intersection(mannheim) ``` ] -- .pull-right[ ```r ggplot() + geom_sf(data = mannheim, fill = NA) + geom_sf(data = roads) + geom_sf(data = buildings) + ggsn::blank() ``` <img src="data:image/png;base64,#MZES_SSDL_Georeferenced_Survey_Data_files/figure-html/map-osm-buildings-1.png" style="display: block; margin: auto;" /> ] --- ## A Fake-Life Application .pull-left[ Let's sample 1,000 people to interview them about their Corona experiences. We can draw a fake sample this way and also add an identifier for the respondents: ```r fake_coordinates <- sf::st_sample(mannheim, 1000) %>% sf::st_sf() %>% dplyr::mutate( id_2 = stringi::stri_rand_strings( 10000, 10 ) %>% sample(1000, replace = FALSE) ) ``` ] -- .pull-right[ ```r ggplot() + geom_sf(data = mannheim, fill = NA) + geom_sf(data = roads) + geom_sf(data = buildings) + geom_sf(data = fake_coordinates) + ggsn::blank() ``` <img src="data:image/png;base64,#MZES_SSDL_Georeferenced_Survey_Data_files/figure-html/map-osm-coordinates-1.png" style="display: block; margin: auto;" /> ] --- ## Correspondence Table As in any survey that deals with addresses, we need a correspondence table of the distinct identifiers. ```r correspondence_table <- dplyr::bind_cols( id = stringi::stri_rand_strings(10000, 10) %>% sample(1000, replace = FALSE), id_2 = fake_coordinates$id_2 ) correspondence_table ``` ``` ## # A tibble: 1,000 x 2 ## id id_2 ## <chr> <chr> ## 1 7h6VelMLl4 LDW4DzkVdj ## 2 mdbRklKLGT rFVZgWTRQO ## 3 urFqmOifoU SOOmLNJNQ2 ## 4 6NOmJjZd0N xXIZROI1jO ## 5 MVIOlvLLDV bNQm2Xmw2R ## 6 2Sr3PUSnXu K7lLvClWKC ## 7 tGI4tB7PCY JqwcvLHhX6 ## 8 m9hG9n1vxp t5jirAGAUx ## 9 Nk48gYmCNx ilO4vZt6cA ## 10 LVFRLKpm4b kRW5wLbSM7 ## # ... with 990 more rows ``` --- ## Conduct the Survey We ask respondents for some standard sociodemographics. But we also apply a new and highly innovative item score, called the Fake Corona Burden Score (FCBS) using the [`faux` package](https://cran.r-project.org/web/packages/faux/index.html). ```r fake_survey_data <- dplyr::bind_cols( id = correspondence_table$id, age = sample(18:100, 1000, replace = TRUE), gender = sample(1:2, 1000, replace = TRUE) %>% as.factor(), education = sample(1:4, 1000, replace = TRUE) %>% as.factor(), income = sample(100:10000, 1000, replace = TRUE), fcbs = secret_variable_i_am_hiding_from_you ) ``` --- ## Survey Data Structure ```r fake_survey_data ``` ``` ## # A tibble: 1,000 x 6 ## id age gender education income fcbs ## <chr> <int> <fct> <fct> <int> <dbl> ## 1 7h6VelMLl4 43 2 3 6537 49.4 ## 2 mdbRklKLGT 56 2 1 4936 37.6 ## 3 urFqmOifoU 94 2 3 6215 55.4 ## 4 6NOmJjZd0N 57 2 1 2779 61.9 ## 5 MVIOlvLLDV 89 2 1 1970 33.4 ## 6 2Sr3PUSnXu 92 1 2 4852 41.7 ## 7 tGI4tB7PCY 95 1 3 7054 53.1 ## 8 m9hG9n1vxp 37 2 4 3502 48.9 ## 9 Nk48gYmCNx 55 2 3 6662 39.2 ## 10 LVFRLKpm4b 83 2 4 5636 56.0 ## # ... with 990 more rows ``` --- ## Adding Geospatial Information Our hypothesis: </br> > The higher the amount of green spaces in the neighborhood, the lower the Fake Corona Burden Score. </br> An excellent data source to test this hypothesis is the Monitor of Settlement and Open Space Development (IOER Monitor). --- ## Function Accessing Python's `OWSLib` .pull-left[ .mini[ ```r #' Retrieve Raster Layer from the IOER Monitor #' Download raster layer from the Monitor of Settlement and Open Space #' Development (IOER Monitor) and load it in your R session. #' #' @param indicator_key character string; indicator key as defined here: #' \url{https://www.ioer-monitor.de/en/indicators/} #' @param size character string; combination of size and unit, e.g., #' \code{"500m"}. ATTENTION: sizes below 200m are currently not working :-( #' @param year character string; reference year for the indicator. ATTENTION: #' not all indicators are available for any year #' @param tmp_folder character string; path where the downloaded and temporary #' file should be stored to reload as raster layer #' #' @importFrom magrittr %>% #' @importFrom reticulate %as% download_ioer_layer <- function ( indicator_key = "S08RG", size = "500m", year = "2019", tmp_folder = "." ) { # create interface to python py <- reticulate::import_builtins() # build web coverage service request indicator_wcs <- paste0("http://maps.ioer.de/cgi-bin/wcs?MAP=", indicator_key, "_wcs") %>% reticulate::import("owslib.wcs")$WebCoverageService(., version = '1.0.0') # retrieve layer name layer_name <- indicator_wcs$contents %>% names() %>% grep(year, ., value = TRUE) %>% grep(size, ., value = TRUE) # identify the actual layer to download, ... layer_to_download <- layer_name %>% indicator_wcs[.] # ...its resolution, ... layer_resolution <- layer_to_download %>% .$grid %>% .$highlimits %>% as.numeric() ... ``` ] ] .pull-right[ .mini[ ```r ... # ...its native coordinate reference system, ... layer_native_crs <- layer_to_download %>% .$boundingboxes %>% .[2] %>% .[[1]] %>% .$nativeSrs # ...and its bounding box layer_bounding_box <- layer_to_download %>% .$boundingboxes %>% .[2] %>% .[[1]] %>% .$bbox %>% unlist() # download layer downloaded_layer <- indicator_wcs$getCoverage( identifier = layer_name, bbox = layer_bounding_box, format = "GTiff", crs = layer_native_crs, width = layer_resolution[1], height = layer_resolution[2] ) %>% .$read %>% reticulate::py_call(.) # store tmp file with(py$open( paste0(tmp_folder, '/layer.tif'), "wb") %as% file, { file$write(downloaded_layer) } ) # load tmp file as 'native' r raster file raster_layer <- raster::raster(paste0(tmp_folder, '/layer.tif')) raster_layer <- raster::readAll(raster_layer) # delete tmp file unlink(paste0(tmp_folder, '/layer.tif')) # return raster layer raster_layer } ``` ] ] --- ## Green Spaces .pull-left[ ```r source("./R/download_ioer_layer.R") mannheim_green <- download_ioer_layer( indicator_key = "S08RG", size = "500m", year = "2019", tmp_folder = "." ) %>% raster::crop(mannheim) %>% { mannheim_green_for_linking <<- . } %>% raster::rasterToPolygons() %>% sf::st_as_sf() %>% sf::st_transform(3035) %>% sf::st_intersection(mannheim) ``` ] -- .pull-right[ ```r ggplot(mannheim_green) + geom_sf( aes(fill = layer), color = NA ) + scale_fill_distiller( palette = "Greens", direction = 1, guide = FALSE ) + ggsn::blank() ``` <img src="data:image/png;base64,#MZES_SSDL_Georeferenced_Survey_Data_files/figure-html/map-ioer-green-execution-1.png" width="70%" style="display: block; margin: auto;" /> ] --- ## Step I: Spatial Linking .pull-left[ <img src="data:image/png;base64,#MZES_SSDL_Georeferenced_Survey_Data_files/figure-html/map-spatial-linking-1.png" style="display: block; margin: auto;" /> ] -- .pull-right[ ```r fake_coordinates_linked <- fake_coordinates %>% dplyr::mutate( green = raster::extract( mannheim_green_for_linking, . ) ) fake_coordinates_linked ``` ``` ## Simple feature collection with 1000 features and 2 fields ## geometry type: POINT ## dimension: XY ## bbox: xmin: 4206413 ymin: 2923149 xmax: 4218346 ymax: 2942937 ## projected CRS: ETRS89-extended / LAEA Europe ## First 10 features: ## geometry id_2 green ## 1 POINT (4207262 2938021) LDW4DzkVdj 0.0000000 ## 2 POINT (4214841 2934378) rFVZgWTRQO 0.0000000 ## 3 POINT (4213833 2930967) SOOmLNJNQ2 0.4491968 ## 4 POINT (4210985 2936810) xXIZROI1jO 13.8781424 ## 5 POINT (4207912 2940827) bNQm2Xmw2R 0.0000000 ## 6 POINT (4209135 2933565) K7lLvClWKC 0.0000000 ## 7 POINT (4214812 2925883) JqwcvLHhX6 6.1500082 ## 8 POINT (4213148 2930882) t5jirAGAUx 38.7836151 ## 9 POINT (4217177 2933267) ilO4vZt6cA 0.0000000 ## 10 POINT (4209703 2940192) kRW5wLbSM7 0.0000000 ``` ] --- ## Step II: Remove Coordinates & Change Identifiers ```r intermediate_data <- dplyr::left_join( correspondence_table, fake_coordinates_linked %>% sf::st_drop_geometry(), by = "id_2" ) %>% dplyr::select(-id_2) intermediate_data ``` ``` ## # A tibble: 1,000 x 2 ## id green ## <chr> <dbl> ## 1 7h6VelMLl4 0 ## 2 mdbRklKLGT 0 ## 3 urFqmOifoU 0.449 ## 4 6NOmJjZd0N 13.9 ## 5 MVIOlvLLDV 0 ## 6 2Sr3PUSnXu 0 ## 7 tGI4tB7PCY 6.15 ## 8 m9hG9n1vxp 38.8 ## 9 Nk48gYmCNx 0 ## 10 LVFRLKpm4b 0 ## # ... with 990 more rows ``` --- ## Step III: Linking With Survey Data ```r fake_survey_data_linked <- dplyr::left_join( fake_survey_data, intermediate_data, by = "id" ) fake_survey_data_linked ``` ``` ## # A tibble: 1,000 x 7 ## id age gender education income fcbs green ## <chr> <int> <fct> <fct> <int> <dbl> <dbl> ## 1 7h6VelMLl4 43 2 3 6537 49.4 0 ## 2 mdbRklKLGT 56 2 1 4936 37.6 0 ## 3 urFqmOifoU 94 2 3 6215 55.4 0.449 ## 4 6NOmJjZd0N 57 2 1 2779 61.9 13.9 ## 5 MVIOlvLLDV 89 2 1 1970 33.4 0 ## 6 2Sr3PUSnXu 92 1 2 4852 41.7 0 ## 7 tGI4tB7PCY 95 1 3 7054 53.1 6.15 ## 8 m9hG9n1vxp 37 2 4 3502 48.9 38.8 ## 9 Nk48gYmCNx 55 2 3 6662 39.2 0 ## 10 LVFRLKpm4b 83 2 4 5636 56.0 0 ## # ... with 990 more rows ``` --- ## Step IV: Analysis .pull-left[ ```r fancy_model <- lm( fcbs ~ age + gender + education + income + green, data = fake_survey_data_linked ) sjPlot::plot_model( fancy_model, type = "pred", terms = "green" ) ``` ] .pull-right[ <img src="data:image/png;base64,#MZES_SSDL_Georeferenced_Survey_Data_files/figure-html/analysis-execution-1.png" style="display: block; margin: auto;" /> ] --- class: center, middle ## What’s Also Quite Handy --- ## Adding It All Together Is a Bit Sad .pull-left[ ```r ggplot() + geom_sf(data = mannheim) + geom_sf(data = roads) + geom_sf(data = buildings) + geom_sf( data = mannheim_green, aes(fill = layer), color = NA ) + scale_fill_distiller( palette = "Greens", direction = 1, guide = FALSE ) + ggsn::blank() ``` ] .pull-right[ <img src="data:image/png;base64,#MZES_SSDL_Georeferenced_Survey_Data_files/figure-html/map-all-4-execution-1.png" style="display: block; margin: auto;" /> ] --- ## Solution 1: Transparency .pull-left[ ```r ggplot() + geom_sf(data = mannheim) + geom_sf(data = roads) + geom_sf(data = buildings) + geom_sf( data = mannheim_green, aes(fill = layer), alpha = .5, color = NA ) + scale_fill_distiller( palette = "Greens", direction = 1, guide = FALSE ) + ggsn::blank() ``` ] .pull-right[ <img src="data:image/png;base64,#MZES_SSDL_Georeferenced_Survey_Data_files/figure-html/map-all-alpha-execution-1.png" style="display: block; margin: auto;" /> ] --- ## Solution 2: A 3d Map! We've learned that simple feature data in `R` basically comprise flat data files. ```r mannheim ``` ``` ## Simple feature collection with 1 feature and 0 fields ## geometry type: MULTIPOLYGON ## dimension: XY ## bbox: xmin: 4206252 ymin: 2923007 xmax: 4218767 ymax: 2943155 ## projected CRS: ETRS89-extended / LAEA Europe ## geometry ## 1 MULTIPOLYGON (((4209130 293... ``` -- They have a column to define the actual geographic structure. ```r mannheim$geometry[[1]] ``` ``` ## MULTIPOLYGON (((4209130 2930959, 4209138 2930946, 4209141 2930942, 4209170 2930899, 4209174 2930892, 4209192 2930865, 4209223 2930816, 4209238 2930793, 4209287 2930714, 4209310 2930673, 4209336 2930628, 4209364 2930574, 4209383 2930536, 4209402 2930495, 4209410 2930477, 4209426 2930443, 4209451 2930385, 4209455 2930375, 4209466 2930346, 4209504 2930257, 4209542 2930167, 4209577 2930075, 4209608 2929986, 4209622 2929939, 4209633 2929894, 4209643 2929854, 4209651 2929810, 4209654 2929767, 4209655 2929723, 4209653 2929693, 4209651 2929665, 4209648 2929638, 4209641 2929597, 4209631 2929552, 4209620 2929512, 4209606 2929469, 4209592 2929433, 4209573 2929391, 4209551 2929353, 4209527 2929314, 4209504 2929283, 4209472 2929244, 4209441 2929211, 4209405 2929178, 4209369 2929148, 4209364 2929144, 4209334 2929122, 4209296 2929100, 4209256 2929079, 4209221 2929061, 4209177 2929043, 4209134 2929025, 4209085 2929009, 4208991 2928976, 4208898 2928946, 4208804 2928915, 4208715 2928887, 4208672 2928872, 4208670 2928871, 4208639 2928860, 4208611 2928849, 4208592 2928841, 4208566 2928830, 4208537 2928816, 4208508 2928801, 4208497 2928796, 4208462 2928776, 4208418 2928750, 4208395 2928734, 4208345 2928694, 4208320 2928673, 4208241 2928593, 4208211 2928557, 4208178 2928512, 4208171 2928504, 4208171 2928504, 4208146 2928466, 4208113 2928408, 4208091 2928368, 4208075 2928331, 4208064 2928307, 4208050 2928266, 4208033 2928217, 4208027 2928199, 4208018 2928159, 4208012 2928134, 4208006 2928108, 4208003 2928090, 4207999 2928060, 4207996 2928028, 4207994 2927999, 4207992 2927981, 4207992 2927971, 4207992 2927940, 4207992 2927907, 4207993 2927882, 4207994 2927865, 4207996 2927840, 4207999 2927811, 4208004 2927784, 4208011 2927749, 4208022 2927710, 4208035 2927664, 4208045 2927634, 4208059 2927598, 4208076 2927556, 4208088 2927527, 4208105 2927495, 4208120 2927465, 4208139 2927431, 4208168 2927386, 4208196 2927341, 4208224 2927305, 4208231 2927296, 4208266 2927253, 4208274 2927244, 4208294 2927224, 4208317 2927202, 4208345 2927174, 4208367 2927156, 4208396 2927133, 4208436 2927099, 4208520 2927035, 4208563 2927008, 4208612 2926976, 4208664 2926948, 4208708 2926926, 4208763 2926902, 4208810 2926883, 4208863 2926865, 4208914 2926848, 4208935 2926843, 4208950 2926840, 4208973 2926834, 4209016 2926825, 4209072 2926814, 4209119 2926804, 4209182 2926794, 4209225 2926788, 4209275 2926781, 4209322 2926774, 4209378 2926769, 4209422 2926764, 4209480 2926760, 4209498 2926759, 4209523 2926757, 4209579 2926754, 4209629 2926752, 4209684 2926750, 4209733 2926751, 4209791 2926751, 4209839 2926752, 4209901 2926755, 4209942 2926756, 4209992 2926759, 4210043 2926763, 4210097 2926766, 4210143 2926770, 4210214 2926775, 4210242 2926777, 4210291 2926781, 4210326 2926783, 4210340 2926784, 4210369 2926786, 4210391 2926788, 4210441 2926792, 4210540 2926798, 4210639 2926805, 4210737 2926810, 4210801 2926812, 4210834 2926813, 4210932 2926814, 4210976 2926813, 4211030 2926812, 4211127 2926808, 4211223 2926802, 4211252 2926800, 4211321 2926795, 4211417 2926785, 4211514 2926772, 4211611 2926759, 4211706 2926744, 4211801 2926726, 4211894 2926707, 4211945 2926694, 4211982 2926684, 4212029 2926670, 4212069 2926656, 4212118 2926636, 4212150 2926622, 4212195 2926600, 4212231 2926582, 4212277 2926554, 4212310 2926533, 4212321 2926526, 4212346 2926508, 4212352 2926504, 4212377 2926487, 4212387 2926479, 4212435 2926436, 4212458 2926412, 4212503 2926367, 4212513 2926355, 4212545 2926319, 4212550 2926313, 4212579 2926276, 4212607 2926233, 4212642 2926177, 4212664 2926134, 4212683 2926096, 4212699 2926052, 4212719 2926006, 4212731 2925969, 4212747 2925918, 4212755 2925883, 4212761 2925861, 4212768 2925830, 4212774 2925796, 4212781 2925754, 4212784 2925710, 4212787 2925665, 4212788 2925620, 4212787 2925576, 4212785 2925528, 4212779 2925482, 4212773 2925434, 4212764 2925390, 4212754 2925344, 4212743 2925305, 4212729 2925258, 4212715 2925218, 4212697 2925173, 4212657 2925087, 4212616 2924995, 4212575 2924904, 4212533 2924813, 4212491 2924720, 4212451 2924630, 4212359 2924432, 4212315 2924320, 4212289 2924259, 4212253 2924160, 4212230 2924101, 4212198 2924017, 4212152 2923888, 4212129 2923817, 4212103 2923738, 4212085 2923680, 4212069 2923623, 4212056 2923584, 4212039 2923522, 4212028 2923485, 4212012 2923419, 4212003 2923385, 4211984 2923315, 4211974 2923270, 4211962 2923217, 4211954 2923181, 4211947 2923145, 4212050 2923155, 4212355 2923185, 4212365 2923096, 4212380 2923111, 4212409 2923140, 4212459 2923179, 4212483 2923195, 4212505 2923208, 4212531 2923221, 4212555 2923233, 4212602 2923254, 4212700 2923290, 4212731 2923298, 4212754 2923305, 4212773 2923312, 4212824 2923325, 4212850 2923334, 4212875 2923344, 4212900 2923354, 4212930 2923366, 4213006 2923404, 4213087 2923465, 4213137 2923506, 4213193 2923555, 4213218 2923573, 4213258 2923602, 4213290 2923622, 4213308 2923632, 4213355 2923639, 4213396 2923641, 4213435 2923642, 4213518 2923650, 4213561 2923656, 4213600 2923683, 4213668 2923729, 4213720 2923765, 4213729 2923774, 4213743 2923787, 4213758 2923805, 4213771 2923828, 4213781 2923853, 4213786 2923887, 4213787 2923892, 4213954 2923829, 4213973 2923800, 4213971 2923677, 4213971 2923531, 4213962 2923531, 4213949 2923416, 4213946 2923402, 4213891 2923123, 4214051 2923174, 4214055 2923175, 4214082 2923183, 4214097 2923189, 4214109 2923198, 4214116 2923199, 4214128 2923203, 4214136 2923193, 4214143 2923181, 4214156 2923157, 4214172 2923126, 4214199 2923097, 4214212 2923077, 4214221 2923063, 4214248 2923007, 4214306 2923033, 4214310 2923034, 4214591 2923227, 4214632 2923222, 4214861 2923190, 4214939 2923179, 4215013 2923169, 4215087 2923157, 4215145 2923143, 4215265 2923114, 4215271 2923113, 4215305 2923169, 4215270 2923239, 4215257 2923267, 4215251 2923279, 4215236 2923308, 4215208 2923367, 4215142 2923509, 4215091 2923623, 4215097 2923625, 4215103 2923628, 4215109 2923631, 4215229 2923668, 4215316 2923695, 4215354 2923644, 4215365 2923611, 4215399 2923505, 4215421 2923502, 4215440 2923488, 4215450 2923496, 4215479 2923517, 4215485 2923521, 4215502 2923496, 4215506 2923514, 4215515 2923567, 4215519 2923611, 4215519 2923636, 4215517 2923661, 4215514 2923686, 4215510 2923730, 4215508 2923759, 4215603 2923762, 4215661 2923764, 4215720 2923767, 4215780 2923771, 4216036 2923777, 4216120 2923780, 4216290 2923787, 4216373 2923790, 4216458 2923791, 4216547 2923793, 4216630 2923795, 4216715 2923799, 4216800 2923801, 4216882 2923803, 4216965 2923801, 4216925 2923681, 4217006 2923656, 4217114 2923635, 4217156 2923627, 4217206 2923618, 4217274 2923595, 4217344 2923571, 4217410 2923557, 4217473 2923544, 4217464 2923628, 4217461 2923671, 4217460 2923706, 4217461 2923744, 4217464 2923796, 4217465 2923820, 4217467 2923844, 4217468 2923863, 4217467 2923916, 4217486 2923999, 4217493 2924038, 4217497 2924068, 4217498 2924100, 4217497 2924129, 4217492 2924209, 4217476 2924379, 4217472 2924416, 4217550 2924461, 4217626 2924504, 4217633 2924497, 4217773 2924575, 4217810 2924595, 4217960 2924695, 4218072 2924721, 4218119 2924723, 4218184 2924725, 4218304 2924896, 4218228 2924940, 4218188 2924965, 4218279 2925092, 4218278 2925099, 4218278 2925105, 4218289 2925119, 4218378 2925233, 4218380 2925250, 4218506 2925423, 4218540 2925469, 4218535 2925499, 4218514 2925619, 4218504 2925617, 4218469 2925829, 4218480 2925832, 4218475 2925862, 4218457 2925974, 4218444 2925990, 4218433 2926051, 4218421 2926113, 4218432 2926115, 4218399 2926289, 4218390 2926290, 4218384 2926324, 4218374 2926379, 4218373 2926383, 4218235 2926394, 4218237 2926478, 4218237 2926511, 4218238 2926559, 4218129 2926560, 4218123 2926560, 4218119 2926622, 4218118 2926638, 4218119 2926712, 4218072 2926714, 4218080 2926726, 4218092 2926745, 4217999 2926800, 4217989 2926783, 4217908 2926831, 4217867 2926827, 4217850 2926826, 4217898 2926903, 4217912 2926926, 4217931 2926959, 4217937 2926969, 4218038 2927141, 4218041 2927148, 4218060 2927192, 4218143 2927332, 4218216 2927455, 4218238 2927494, 4218289 2927581, 4218294 2927588, 4218302 2927601, 4218450 2927852, 4218486 2927914, 4218520 2927973, 4218521 2927976, 4218527 2927986, 4218531 2927992, 4218535 2927999, 4218612 2928131, 4218736 2928338, 4218767 2928388, 4218754 2928392, 4218744 2928395, 4218734 2928398, 4218723 2928402, 4218705 2928409, 4218692 2928414, 4218664 2928421, 4218443 2928477, 4218405 2928500, 4218369 2928471, 4218347 2928454, 4218328 2928441, 4218304 2928430, 4218256 2928409, 4218226 2928397, 4218193 2928385, 4218160 2928376, 4218124 2928368, 4218097 2928366, 4218056 2928365, 4218031 2928367, 4217986 2928372, 4217936 2928382, 4217890 2928393, 4217845 2928406, 4217817 2928418, 4217769 2928438, 4217700 2928468, 4217685 2928476, 4217646 2928497, 4217618 2928516, 4217575 2928561, 4217375 2928722, 4217311 2928787, 4217261 2928838, 4217261 2928839, 4217267 2928857, 4217270 2928869, 4217277 2928894, 4217252 2928906, 4217236 2928920, 4217225 2928931, 4217207 2928947, 4217190 2928965, 4217174 2928987, 4217160 2929008, 4217145 2929033, 4217139 2929043, 4217130 2929058, 4217115 2929089, 4217103 2929116, 4217093 2929138, 4217062 2929212, 4217035 2929279, 4217031 2929288, 4216997 2929366, 4216965 2929444, 4216930 2929522, 4216897 2929599, 4216860 2929675, 4216822 2929747, 4216808 2929775, 4216782 2929825, 4216748 2929878, 4216697 2929955, 4216680 2929985, 4216644 2930048, 4216600 2930107, 4216546 2930170, 4216504 2930213, 4216476 2930246, 4216445 2930272, 4216423 2930290, 4216400 2930303, 4216369 2930319, 4216342 2930333, 4216321 2930342, 4216292 2930354, 4216256 2930366, 4216204 2930381, 4216169 2930389, 4216114 2930404, 4216033 2930423, 4215939 2930442, 4215904 2930449, 4215871 2930453, 4215823 2930456, 4215777 2930457, 4215739 2930457, 4215703 2930454, 4215652 2930452, 4215621 2930450, 4215596 2930447, 4215562 2930442, 4215532 2930435, 4215447 2930423, 4215489 2930569, 4215504 2930574, 4215516 2930628, 4215530 2930680, 4215549 2930755, 4215565 2930806, 4215579 2930848, 4215589 2930876, 4215622 2930963, 4215639 2931000, 4215732 2931197, 4215926 2931541, 4215961 2931602, 4215988 2931639, 4216034 2931723, 4216109 2931861, 4216148 2931929, 4216237 2931974, 4216269 2931985, 4216306 2931994, 4216338 2932001, 4216370 2932008, 4216397 2932014, 4216426 2932020, 4216460 2932027, 4216498 2932035, 4216533 2932041, 4216555 2932044, 4216585 2932048, 4216613 2932051, 4216644 2932054, 4216666 2932056, 4216682 2932056, 4216706 2932055, 4216746 2932050, 4216834 2932039, 4216874 2932054, 4216900 2932064, 4216929 2932075, 4217001 2932116, 4217030 2932134, 4217117 2932117, 4217122 2932124, 4217132 2932135, 4217139 2932144, 4217150 2932156, 4217160 2932166, 4217169 2932174, 4217180 2932181, 4217192 2932188, 4217204 2932193, 4217213 2932197, 4217249 2932208, 4217300 2932223, 4217467 2932267, 4217682 2932321, 4217540 2932594, 4217572 2932615, 4217622 2932649, 4217639 2932661, 4217672 2932684, 4217710 2932708, 4217762 2932740, 4217843 2932787, 4217949 2932848, 4217997 2932874, 4218042 2932896, 4218098 2932918, 4218137 2932933, 4218208 2932960, 4218264 2932980, 4218287 2932990, 4218345 2933014, 4218394 2933036, 4218470 2933076, 4218642 2933165, 4218557 2933325, 4218477 2933480, 4218303 2933813, 4218305 2933818, 4218383 2933856, 4218419 2933872, 4218410 2933877, 4218359 2933927, 4218247 2934010, 4218250 2934014, 4218259 2934027, 4218249 2934034, 4218351 2934193, 4218380 2934220, 4218461 2934271, 4218493 2934278, 4218528 2934278, 4218548 2934289, 4218345 2934440, 4218342 2934446, 4218353 2934559, 4218382 2934855, 4218401 2935043, 4218398 2935050, 4218262 2935100, 4218263 2935104, 4218110 2935157, 4217860 2935242, 4217854 2935223, 4217671 2935309, 4217626 2935193, 4217532 2935259, 4217502 2935222, 4217418 2935146, 4217229 2935051, 4217042 2935110, 4216974 2935131, 4216780 2935206, 4216729 2935225, 4216445 2935337, 4216416 2935361, 4216253 2935510, 4216094 2935654, 4215806 2935829, 4215464 2936074, 4215423 2936120, 4214986 2936708, 4214762 2937009, 4214357 2938299, 4214357 2938300, 4214338 2938323, 4214279 2938397, 4214186 2938512, 4214081 2938642, 4214080 2938643, 4214081 2938645, 4214082 2938646, 4213818 2938964, 4213695 2939117, 4213682 2939132, 4213678 2939137, 4213674 2939143, 4213616 2939215, 4213591 2939241, 4213588 2939245, 4213583 2939253, 4213563 2939285, 4213525 2939331, 4213466 2939402, 4213405 2939476, 4213341 2939551, 4213296 2939606, 4213295 2939607, 4213199 2939724, 4213114 2939827, 4213104 2939839, 4213008 2939955, 4212915 2940067, 4212897 2940090, 4212841 2940158, 4212765 2940248, 4212576 2940468, 4212560 2940487, 4212486 2940577, 4212473 2940596, 4212429 2940665, 4212393 2940720, 4212338 2940810, 4212297 2940878, 4212274 2940915, 4212148 2941118, 4212140 2941133, 4212139 2941134, 4212136 2941140, 4212137 2941148, 4212064 2941163, 4211992 2941175, 4211823 2941205, 4211814 2941206, 4211606 2941243, 4211201 2941318, 4211201 2941321, 4211190 2941323, 4211179 2941325, 4211181 2941688, 4210967 2941830, 4210793 2941945, 4210667 2942029, 4210661 2942148, 4210660 2942160, 4210796 2942435, 4210793 2942436, 4210564 2942519, 4210522 2942556, 4210416 2942645, 4210391 2942666, 4210331 2942716, 4210265 2942770, 4210198 2942819, 4210094 2942896, 4210069 2942914, 4210061 2942922, 4209970 2943021, 4209905 2943034, 4209896 2943035, 4209817 2943039, 4209726 2943043, 4209457 2943081, 4209431 2943083, 4209417 2943085, 4209401 2943086, 4209293 2943099, 4209117 2943119, 4209005 2943132, 4208914 2943143, 4208843 2943146, 4208822 2943147, 4208733 2943155, 4208644 2943147, 4208582 2943132, 4208581 2943135, 4208491 2943114, 4208436 2943097, 4208388 2943082, 4208350 2943073, 4208321 2943069, 4208308 2943066, 4208302 2943065, 4208303 2943062, 4208238 2943049, 4208218 2943045, 4208216 2943045, 4208222 2943014, 4208230 2942949, 4208223 2942861, 4208215 2942795, 4208197 2942720, 4208170 2942631, 4208152 2942579, 4208127 2942538, 4208058 2942435, 4208054 2942435, 4207931 2942456, 4207779 2942481, 4207631 2942506, 4207440 2942537, 4207227 2942515, 4207125 2942504, 4207117 2942503, 4207107 2942502, 4207088 2942500, 4207067 2942489, 4206926 2942416, 4206952 2942323, 4206968 2942233, 4206981 2942148, 4206992 2942059, 4206998 2941966, 4206998 2941873, 4206994 2941781, 4206985 2941691, 4206971 2941599, 4206952 2941508, 4206931 2941424, 4206903 2941340, 4206868 2941251, 4206852 2941214, 4206829 2941165, 4206782 2941075, 4206729 2940988, 4206671 2940904, 4206614 2940816, 4206560 2940723, 4206512 2940635, 4206468 2940542, 4206428 2940449, 4206389 2940358, 4206355 2940264, 4206319 2940149, 4206300 2940047, 4206283 2939948, 4206270 2939842, 4206260 2939735, 4206253 2939627, 4206252 2939521, 4206256 2939414, 4206264 2939305, 4206277 2939198, 4206295 2939093, 4206317 2938993, 4206347 2938891, 4206379 2938788, 4206415 2938690, 4206443 2938619, 4206455 2938590, 4206466 2938567, 4206468 2938563, 4206471 2938558, 4206474 2938553, 4206476 2938547, 4206504 2938490, 4206557 2938390, 4206608 2938304, 4206661 2938217, 4206714 2938134, 4206761 2938047, 4206802 2937959, 4206835 2937877, 4206865 2937791, 4206869 2937775, 4206889 2937704, 4206893 2937692, 4206912 2937612, 4206934 2937526, 4206959 2937426, 4206986 2937324, 4207010 2937225, 4207035 2937128, 4207060 2937030, 4207084 2936935, 4207109 2936837, 4207134 2936741, 4207158 2936644, 4207183 2936548, 4207208 2936450, 4207232 2936354, 4207257 2936257, 4207280 2936160, 4207306 2936063, 4207330 2935966, 4207354 2935869, 4207379 2935774, 4207404 2935675, 4207429 2935578, 4207453 2935481, 4207478 2935385, 4207503 2935287, 4207527 2935190, 4207553 2935092, 4207577 2934995, 4207601 2934902, 4207625 2934807, 4207650 2934706, 4207675 2934609, 4207699 2934512, 4207712 2934462, 4207713 2934451, 4207714 2934438, 4207714 2934411, 4207712 2934361, 4207713 2934351, 4207714 2934342, 4207715 2934333, 4207718 2934318, 4207726 2934288, 4207752 2934186, 4207755 2934166, 4207793 2934019, 4207816 2933930, 4207839 2933835, 4207864 2933738, 4207876 2933686, 4207890 2933638, 4207907 2933564, 4207914 2933535, 4207939 2933438, 4207963 2933343, 4207987 2933245, 4208011 2933153, 4208022 2933108, 4208033 2933062, 4208041 2933016, 4208047 2932983, 4208050 2932968, 4208062 2932873, 4208076 2932773, 4208082 2932723, 4208088 2932673, 4208097 2932620, 4208106 2932573, 4208113 2932536, 4208122 2932499, 4208130 2932467, 4208147 2932400, 4208154 2932376, 4208159 2932360, 4208179 2932300, 4208195 2932257, 4208225 2932175, 4208234 2932154, 4208277 2932060, 4208297 2932027, 4208311 2932003, 4208333 2931966, 4208338 2931960, 4208345 2931951, 4208351 2931941, 4208357 2931932, 4208361 2931926, 4208377 2931904, 4208395 2931878, 4208412 2931858, 4208448 2931814, 4208464 2931796, 4208530 2931719, 4208598 2931642, 4208652 2931581, 4208664 2931566, 4208728 2931493, 4208789 2931421, 4208854 2931339, 4208910 2931266, 4208967 2931188, 4209024 2931110, 4209066 2931049, 4209082 2931027, 4209109 2930989, 4209114 2930981, 4209118 2930976, 4209122 2930971, 4209126 2930964, 4209130 2930959))) ``` --- ## Shear Rotation Function These geometry columns can be manipulated, e.g., by rotating them with a shear transformation. .small[ ```r #' Rotate simple features for 3D layers #' Rotates a simple features layer using a shear matrix transformation on the #' \code{geometry} column. This can get nice for visualisation and works with #' points, lines and polygons. #' #' @param data an object of class \code{sf} #' @param x_add integer; x value to move geometry in space #' @param y_add integer; x value to move geometry in space #' #' #' @importFrom magrittr %>% rotate_sf <- function(data, x_add = 0, y_add = 0) { shear_matrix <- function (x) { matrix(c(2, 1.2, 0, 1), 2, 2) } rotate_matrix <- function(x) { matrix(c(cos(x), sin(x), -sin(x), cos(x)), 2, 2) } data %>% dplyr::mutate( geometry = .$geometry * shear_matrix() * rotate_matrix(pi / 20) + c(x_add, y_add) ) } ``` ] --- ## Voilà! Now we are able to build 3D layers that separate the data sources from each other. .pull-left[ .small[ ```r ggplot() + geom_sf( data = rotate_sf(mannheim), fill = NA ) + geom_sf( data = rotate_sf(roads) ) + geom_sf( data = rotate_sf(buildings) ) + geom_sf( data = rotate_sf(fake_coordinates, y_add = 12000) ) + geom_sf( data = rotate_sf(mannheim_green, y_add = 24000), aes(fill = layer), color = NA ) + scale_fill_distiller( palette = "Greens", direction = 1, guide = FALSE ) + ggsn::blank() ``` ] ] .pull-right[ <img src="data:image/png;base64,#MZES_SSDL_Georeferenced_Survey_Data_files/figure-html/map-all-3d-execution-1.png" style="display: block; margin: auto;" /> ] --- ## References I .tinyisher[ Allport, Gordon W. 1954. The Nature of Prejudice. Cambridge, Massachusetts: Addison-Wesley Publishing Company. Banton, Michael. 1983. Racial and Ethnic Competition. Comparative Ethnic and Race Relations Series. Cambridge & New York: Cambridge University Press. Blalock, H. M. 1967. Toward a Theory of Minority-Group Relations. New York: Wiley. Blumer, Herbert. 1958. “Race Prejudice as a Sense of Group Position.” The Pacific Sociological Review 1 (1): 3--7. https://doi.org/10.2307/1388607. Bodenmann, Guy. 1997. “Dyadic Coping: A Systemic-Transactional View of Stress and Coping among Couples: Theory and Empirical Findings.” European Review of Applied Psychology 47 (2): 137–41. Bowyer, Benjamin. 2008. “Local Context and Extreme Right Support in England: The British National Party in the 2002 and 2003 Local Elections.” Electoral Studies 27 (4): 611–20. City of Cologne. 2014. “City Districts Shapefiles.” 2014. Retrieved September 28, 2018, from https://offenedaten-koeln.de/sites/default/files/Stadtteil.zip. Crowder, Kyle, and Liam Downey. 2010. “Inter-Neighborhood Migration, Race, and Environmental Hazards: Modeling Micro-Level Processes of Environmental Inequality.” American Journal of Sociology 115 (4): 1110–1149. Federal Agency for Cartography and Geodesy. 2018. “Administrative Areas 2018 Shapefiles.” 2018. Retrieved May 29, 2018, from https://www.geodatenzentrum.de/geodaten/gdz_rahmen.gdz_div?gdz_spr=eng&gdz_akt_zeile=5&gdz_anz_zeile=1&gdz_unt_zeile=14&gdz_user_id=0. GESIS - Leibniz Institute for the Social Sciences. 2015. “ALLBUS/GGSS 2014 (Allgemeine Bevölkerungsumfrage Der Sozialwissenschaften/German General Social Survey 2014).” GESIS Data Archive. http://dx.doi.org/10.4232/1.12209. ———. 2018. “ALLBUS/GGSS (Allgemeine Bevölkerungsumfrage der Sozialwissenschaften/German General Social Survey) - Sensitive Regional Data.” GESIS Data Archive. https://doi.org/10.4232/1.13010. **Jünger, Stefan. 2019. Using Georeferenced Data in Social Science Survey Research. The Method of Spatial Linking and Its Application with the German General Social Survey and the GESIS Panel. GESIS-Schriftenreihe 24. Köln: GESIS - Leibniz-Institut für Sozialwissenschaften. 10.21241/ssoar.63688.** ] --- ## References II .tinyisher[ Klinger, Julia, Stefan Müller, and Merlin Schaeffer. 2017. “Der Halo-Effekt in Einheimisch-Homogenen Nachbarschaften: Steigert Die Ethnische Diversität Angrenzender Nachbarschaften Die Xenophobie?” Zeitschrift Für Soziologie 46 (6): 402–19. https://doi.org/10.1515/zfsoz-2017-1022. Leibniz Institute of Ecological Urban and Regional Development. 2018. “Soil Sealing. Monitor of Settlement and Open Space Development.” 2018. Retrieved October 2, 2018, from http://monitor.ioer.de/cgi-bin/wcs?MAP=S40RG_wcs. Lersch, Philipp M. 2013. “Place Stratification or Spatial Assimilation? Neighbourhood Quality Changes after Residential Mobility for Migrants in Germany.” Urban Studies 50 (5): 1011–29. https://doi.org/10.1177/0042098012464403. OpenStreetMap / GEOFABRIK. 2020. “Regierungsbezirk Köln Shapefiles.” 2020. https://download.geofabrik.de/europe/germany/nordrhein-westfalen/koeln-regbez-latest-free.shp.zip. Park, Robert E., Ernest W. Burgess, and Roderick D. McKenzie. 1925. The City. Suggestions for Investigation of Human Behavior in the Urban Environment. Chicago and London: University of Chicago Press. Pearlin, Leonard I., Scott Schieman, Elena M. Fazio, and Stephen C. Meersman. 2005. “Stress, Health, and the Life Course: Some Conceptual Perspectives.” Journal of Health and Social Behavior 46 (2): 205–19. https://doi.org/10.1177/002214650504600206. Petrović, Ana, David Manley, and Maarten van Ham. 2019. “Freedom from the Tyranny of Neighbourhood: Rethinking Sociospatial Context Effects.” Progress in Human Geography. https://doi.org/10.1177/0309132519868767. Rydgren, Jens, and Patrick Ruth. 2013. “Contextual Explanations of Radical Right-Wing Support in Sweden: Socioeconomic Marginalization, Group Threat, and the Halo Effect.” Ethnic and Racial Studies 36 (4): 711–28. Siegfried, André. 1913. Tableau Politique de La France de l’Ouest Sous La Troisième République. Paris: Collin. Statistical Office of the European Union Eurostat. 2018. “World Shapefiles in EPSG:3857 and EPSG:3035.” 2018. Retrieved October 08, 2018, from https://ec.europa.eu/eurostat/cache/GISCO/distribution/v2/nuts/download/ref-nuts-2016-01m.shp.zip. Statistical Offices of the Federation and the Länder. 2016. “Immigrant Rates. German Census 2011.” 2016. Retrieved 06 November, 2016, from https://github.com/stefmue/georefum/blob/master/data/census.attr.rda. Stephan, Walter G., Oscar Ybarra, and Kimberly Rios Morrison. 2009. “Intergroup Threat Theory.” In Handbook of Prejudice, Stereotyping, and Discrimination, edited by T. Nelson, 43–60. New Jersey: Psychology Press. Thoits, Peggy A. 2011. “Mechanisms Linking Social Ties and Support to Physical and Mental Health.” Journal of Health and Social Behavior 52 (2): 145–61. https://doi.org/10.1177/0022146510395592. ] --- ## GIFs & Memes Angry cat: https://giphy.com/gifs/VbnUQpnihPSIgIXuZv Trump: https://imgflip.com/memegenerator/Trump-Bill-Signing Hacker man: https://i.kym-cdn.com/entries/icons/original/000/021/807/ig9OoyenpxqdCQyABmOQBZDI0duHk2QZZmWg2Hxd4ro.jpg IT crowd: https://66.media.tumblr.com/0e4f270fdebf2bbbc8a61ddae1cd13de/tumblr_mz7ksjhYpi1s6banvo1_250.gif --- layout: false class: center background-image: url(data:image/png;base64,#./auxiliarily_files/img/the_end.png) background-size: cover .left-column[ </br> <img src="data:image/png;base64,#./auxiliarily_files/img/me.png" width="90%" style="display: block; margin: auto;" /> ] .right-column[ .left[.small[
[`stefan.juenger@gesis.org`](mailto:stefan.juenger@gesis.org)] </br> .small[
[`@StefanJuenger`](https://twitter.com/StefanJuenger)] </br> .small[
[`StefanJuenger`](https://github.com/StefanJuenger)] </br> .small[
[`https://stefanjuenger.github.io`](https://stefanjuenger.github.io)]] </br> ]